package com.example.calculater2;

import androidx.appcompat.app.AppCompatActivity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class jian extends Activity  implements  View.OnClickListener {
    EditText etX;
    EditText etY;
    Button btn;
    TextView tvResult;
    Button back;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.jian);
        setViews();

    }
    public void setViews(){
        etX = (EditText)findViewById(R.id.edX);
        etY = (EditText)findViewById(R.id.edY);
        btn = (Button)findViewById(R.id.btn);
        tvResult = (TextView)findViewById(R.id.tvResult);
        back = (Button)findViewById(R.id.back);
        btn.setOnClickListener(this);
        back.setOnClickListener(this::click);

    }
    @Override
    public void onClick(View v) {
        int x = Integer.parseInt(etX.getText().toString());
        int y = Integer.parseInt(etY.getText().toString());
        int z = x-y;
        tvResult.setText("计算结果为：" + z);

    }
    public void click(View view){
        finish();
    }
}